Add configurable payload size limit for Express server#13
Add configurable payload size limit for Express server#13lutzleonhardt wants to merge 2 commits intomasterfrom
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
| // Middleware to parse JSON bodies with configurable limit | ||
|
|
||
| // Logger middleware | ||
| app.use(morgan('combined')); | ||
| ======= | ||
| const payloadLimit = process.env.PAYLOAD_LIMIT || '50mb'; | ||
| app.use(express.json({ limit: payloadLimit })); | ||
|
|
||
| // Logger middleware | ||
| app.use(morgan('combined')); | ||
| ======= |
There was a problem hiding this comment.
Suggestion: Clean up conflict markers and duplicate middleware
| // Middleware to parse JSON bodies with configurable limit | |
| // Logger middleware | |
| app.use(morgan('combined')); | |
| ======= | |
| const payloadLimit = process.env.PAYLOAD_LIMIT || '50mb'; | |
| app.use(express.json({ limit: payloadLimit })); | |
| // Logger middleware | |
| app.use(morgan('combined')); | |
| ======= | |
| // Middleware to parse JSON bodies with configurable limit | |
| const payloadLimit = process.env.PAYLOAD_LIMIT || '50mb'; | |
| app.use(express.json({ limit: payloadLimit })); | |
| // Logger middleware | |
| app.use(morgan('combined')); |
User description
This pull request introduces a configurable payload size limit for the Copilot Proxy server to handle larger requests.
Key changes include:
copilotProxy.payloadLimitsetting inpackage.json(defaulting to '50mb') allowing users to customize the maximum request size.express.jsonmiddleware insrc/server.tsto enforce the specified limit, preventing "Payload Too Large" errors during heavy data transfers.Note: There was a slight merge conflict artifact in the provided diff for
src/server.tswhich should be cleaned up during integration.Fixes #4
PR Type
Enhancement
Description
Add configurable payload size limit for Express server
Retrieve payload limit from VS Code configuration settings
Update express.json middleware to enforce payload limit
Enhance server start notification with payload limit info
Add morgan logger middleware for request logging
Diagram Walkthrough
File Walkthrough
extension.ts
Configure and pass payload limit to serversrc/extension.ts
payloadLimitsetting from configurationPAYLOAD_LIMITenvironment variable for server consumptionserver.ts
Apply payload limit and add request loggingsrc/server.ts
package.json
Add payload limit configuration propertypackage.json
copilotProxy.payloadLimitconfiguration property